<?php
namespace App\Http\Middleware;
use Closure;
class LimitFormRepeatSubmit
{
    public function handle($request, Closure $next)
    {
        /****************************************
         * 1. 前端自己生成一个 form_token
         * 2. 如果 session 已经存在，则告诉重复提交
         ****************************************/
        $token = $request->input('form_token');
        if ($request->session()->has($token)) {
            return back()->with('status', '请不要重复提交');
        }
        $request->session()->put($token,'1');
        return $next($request);
    }
}